package cn.wolfcode.crm.query;

import cn.wolfcode.crm.util.DateUtil;
import lombok.Getter;
import lombok.Setter;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Date;

@Getter
@Setter
public class CustomerChartQueryObject extends QueryObject {
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date beginDate;//默认设置为潜在客户
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date endDate;
//给定一个默认的分组类型
    private String groupType = "seller.name";
    public Date getEndDate()
    {
        return DateUtil.getEndDate(endDate);//设置成当天的23:59:59秒
    }

    public String getGroupTypeName() {
        String name = "";
        if("seller.name".equals(groupType))
        {
            name = "员工";
        }else if("DATE_FORMAT(c.input_time, '%Y')".equals(groupType))
        {
            name="年";
        }
        else if("DATE_FORMAT(c.input_time, '%Y-%m')".equals(groupType))
        {
            name="月";
        }
        else if("DATE_FORMAT(c.input_time, '%Y-%m-%d')".equals(groupType))
        {
            name="日";
        }
        return name;
    }
}
